home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
earkit
/
news
/
thor
/
hd-install
/
thor25_arexx.lha
/
AddMIME.thor
next >
Wrap
Text File
|
1997-04-27
|
9KB
|
352 lines
/*
$VER: AddMIME.thor 0.7 (29.11.96)
by Remco van Hooff
Attach a file (MIME) while writing a msg in Thor.
Run from FSE, CED or GED.
Borrowed some code from InsertIt.thor (by Shaun Downend).
HISTORY
0.2 - When the filerequester would be cancelled an empty attacment would be
created.
- No more requester/status bar stating DOC=xxx when using GoldED.
0.3 - When the uploadpath for the current system is not defined the global
upload path is used.
0.4 - Added multiple file attachment support (add, delete, edit).
NOTE: Only the first file, in a list of identical files, will be
edited (replaced), even when the the last of the identical files
was selected.
- Added reading of existing attacments.
0.5 - Fixed an infinite loop occuring when only one file was selected and
no attachment was already present.
0.6 - No more "Attachment:" text when saving an empty attachment string (no
attachments).
- Added archiving (LhA) of selected files.
0.7 - Will not fail on archiving paths/files containing spaces anymore.
*/
lhaoptions = '-U8192 -a -b128 -x -r -e a' /* use the -q flag for no output */
lhapath = 'c:'
/*!~ "Init" */
OPTIONS RESULTS
version = SUBWORD(SOURCELINE(2), 3,1)
title = 'AddMIME' version '© by Remco van Hooff '
p=' '||ADDRESS()||' '||SHOW('P',,)
IF POS(' THOR.',p)>0 THEN thorport=WORD(SUBSTR(p,POS(' THOR.',p)+1),1)
ELSE DO
SAY 'THOR port not found!'
EXIT 10
END
IF ~SHOW('p', 'BBSREAD') THEN DO
ADDRESS COMMAND
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
END
attachments = ''
sep = '01'x
/*~!*/
/*!~ "Get MSGFILE from editor" */
editor.name.1 = 'GOLDED'
editor.filename.1 = 'QUERY DOC VAR filename'
editor.name.2 = 'THOR_FSE'
editor.filename.2 = 'MSGFILENAME'
editor.name.3 = 'rexx_ced'
editor.filename.3 = 'status 21'
editor.count = 3
DO n = 1 TO editor.count
IF(SUBSTR(ADDRESS(),1,LENGTH(editor.name.n)) = editor.name.n) THEN DO
editorport = address()
INTERPRET editor.filename.n
filename = RESULT
IF POS('/', filename) ~= 0 THEN filename = SUBSTR(filename, (LASTPOS('/', filename) + 1))
END
END
IF editorport = '' THEN DO
SAY 'This script has to be run from your editor.'
SAY 'GoldED, FSE (Thor''s internal editor) and CygnusED are currently supported.'
EXIT
END
/*~!*/
/*!~ "Get system/event stuff" */
ADDRESS(thorport)
'CURRENTBBS stem CURRENT'
IF(RC ~= 0 | CURRENT.BBSNAME ~= "") THEN system = CURRENT.BBSNAME
ELSE EXIT
ADDRESS(bbsread)
'GETBBSDATA "'system'" STEM BBSDATA'
IF(RC ~= 0) THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_Ok"'
EXIT 5
END
updir = BBSDATA.UPLOADPATH
IF updir = '' THEN DO
'GETGLOBALDATA STEM GLOBAL'
IF(RC ~= 0) THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_Ok"'
EXIT 5
END
updir = GLOBAL.UPLOADPATH
END
IF POS(':', updir) ~= length(updir) THEN updir = updir'/'
DO i = BBSDATA.FIRSTEVENT TO BBSDATA.LASTEVENT
DROP MSGTAGS. MSGDATA.
'READBREVENT BBSNAME "'system'" EVENTNR 'i' TAGSSTEM MSGTAGS DATASTEM MSGDATA'
IF(RC ~= 0) THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_Ok"'
EXIT 5
END
IF filename = MSGTAGS.MSGFILE THEN attachments = MSGTAGS.LOCALFILE
END
/*~!*/
CALL list_files(attachments)
EXIT
/*!~ "List_files"*/
list_files:
att_files = ARG(1)
IF att_files = 'MSGTAGS.LOCALFILE' THEN att_files = ''
attach = 0
IF att_files ~= '' THEN DO
parse_att_files = att_files
DO UNTIL parse_att_files = ''
attach = attach + 1
PARSE VAR parse_att_files atchfile '01'x parse_att_files
entry.attach = atchfile
END
attach = attach + 1
entry.attach = ''
END
tot = attach + 1
entry.tot = 'Add'
tot = tot +1
entry.tot = 'Archive'
tot = tot +1
entry.tot = 'Accept'
entry.COUNT = tot
ADDRESS(thorport)
'REQUESTLIST INSTEM' entry 'TITLE "'title'" SIZEGADGET'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN EXIT
ELSE DO
option = RESULT
IF UPPER(option) = 'ADD' THEN DO
addfile = add(att_files)
CALL list_files(addfile)
END
IF POS('ACCEPT', UPPER(option)) ~= 0 THEN CALL write_event(att_files)
IF POS('ARCHIVE', UPPER(option)) ~= 0 THEN DO
att_files = archive(att_files)
CALL list_files(att_files)
END
IF attach > 0 THEN DO
DO n = 1 TO attach - 1
IF option = entry.n THEN DO
'REQUESTNOTIFY TEXT "Edit or delete this file? " BT "_Edit|_Delete|_Cancel"'
IF RC = 0 THEN DO
IF RESULT = 0 THEN CALL list_files(att_files)
IF RESULT = 1 THEN CALL list_files(edit(entry.n))
IF RESULT = 2 THEN CALL list_files(del(entry.n, att_files))
END
END
END
END
END
CALL list_files(att_files)
RETURN
/*~!*/
/*!~ "Add"*/
add:
files = ARG(1)
extrafiles = request_file(updir)
IF extrafiles = '' THEN allfiles = files
ELSE allfiles = files || sep || extrafiles
IF POS(sep, allfiles) ~= 0 THEN DO
discard = POS(sep, allfiles)
DO UNTIL discard > 1
IF discard = 1 THEN allfiles = DELSTR(allfiles,1,1)
discard = POS(sep, allfiles)
IF discard = 0 THEN discard = 2
END
END
dub = POS(sep||sep, allfiles)
DO UNTIL dub = 0
IF dub > 0 THEN allfiles = DELSTR(allfiles,dub,1)
dub = POS(sep||sep, allfiles)
END
RETURN(allfiles)
/*~!*/
/* !~ "Del"*/
del:
delfile = ARG(1)
allattfiles = ARG(2)
posdel = POS(delfile, allattfiles)
IF posdel > 0 THEN DO
possep = POS(sep, allattfiles, posdel)
IF possep > posdel THEN remfile = possep - posdel + 1
ELSE remfile = LENGTH(delfile)
allattfiles = DELSTR(allattfiles, posdel, remfile)
END
RETURN(allattfiles)
/*~!*/
/*!~ "Edit"*/
edit:
edfile = ARG(1)
file = SUBSTR(edfile, LASTPOS('/', edfile)+1)
path = SUBSTR(edfile,1, LASTPOS('/', edfile))
ADDRESS(thorport)
'REQUESTFILE TITLE "Edit file." ID "'path'" IF "'file'" FP'
IF RC = 30 THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN RETURN(att_files)
IF RC = 0 THEN DO
newfile = RESULT
part1 = SUBSTR(att_files,1 , POS(edfile, att_files)-1)
part2 = SUBSTR(att_files, POS(edfile, att_files)+LENGTH(edfile))
att_files = part1||newfile||part2
END
RETURN(att_files)
/*~!*/
/*!~ "Request_File" */
request_file:
path = ARG(1)
DROP selfile.
ADDRESS(thorport)
'REQUESTFILE TITLE "Select file(s) to attach." ID "'path'" FP MS OUTSTEM' selfile
IF (RC = 30) THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN RETURN('')
IF RC = 0 THEN DO
fls = ''
IF selfile.COUNT > 1 THEN DO
DO fl = 1 TO selfile.COUNT
fls = fls || sep || selfile.fl
END
END
ELSE fls = selfile.1
END
RETURN(fls)
/*~!*/
/*!~ "Write_Event" */
Write_event:
files = ARG(1)
ADDRESS BBSREAD
DO i = BBSDATA.FIRSTEVENT TO BBSDATA.LASTEVENT
DROP MSGTAGS. MSGDATA.
'READBREVENT BBSNAME "'system'" EVENTNR 'i' TAGSSTEM MSGTAGS DATASTEM MSGDATA'
IF(RC ~= 0) THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_Ok"'
EXIT 5
END
IF(filename = MSGTAGS.MSGFILE) THEN DO
IF files = '' THEN DROP MSGTAGS.LOCALFILE
ELSE MSGTAGS.LOCALFILE = files
WRITEBREVENT BBSNAME '"'system'"' EVENT MSGDATA.EVENTTYPE STEM MSGTAGS UPDATEEVENTNR i
IF(RC ~= 0) THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'BBSREAD.LASTERROR'" BT "_Ok"'
EXIT 5
END
EXIT
END
END
RETURN
/*~!*/
/*!~ "Archive" */
archive:
allarcfiles = ARG(1)
IF allarcfiles = '' THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT " You need to add files first." BT "_Ok"'
CALL list_files(allarcfiles)
END
arc = 0
IF allarcfiles ~= '' THEN DO
parse_allarcfiles = allarcfiles
DO UNTIL parse_allarcfiles = ''
arc = arc + 1
PARSE VAR parse_allarcfiles atchfile '01'x parse_allarcfiles
arclst.arc = atchfile
END
arclst.count = arc
END
ADDRESS(thorport)
DROP arcfiles.
'REQUESTLIST INSTEM' arclst 'OUTSTEM' arcfiles 'TITLE "Select file(s) to archive." SIZEGADGET DRAGSELECT MULTISELECT'
IF (RC = 30) THEN DO
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN RETURN(allarcfiles)
ELSE DO
file = '.lha'
path = updir
ADDRESS(thorport)
'REQUESTFILE TITLE "Edit file." ID "'path'" IF "'file'" FP'
IF RC = 30 THEN DO
ADDRESS(thorport)
'REQUESTNOTIFY TEXT "'THOR.LASTERROR'" BT "_Ok"'
EXIT
END
IF RC = 5 THEN RETURN(allarcfiles)
IF RC = 0 THEN DO
addarcfile = RESULT
allarcfiles = allarcfiles || sep || addarcfile
arc_files = ''
DO f = 1 to arcfiles.COUNT
allarcfiles = del(arcfiles.f, allarcfiles)
arc_files = arc_files' "'arcfiles.f'"'
END
ADDRESS COMMAND lhapath'lha' lhaoptions addarcfile arc_files
END
END
RETURN(allarcfiles)
/*~!*/